/*
 *  Copyright 2010 sonrisa.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package com.zh.jbet.core.tournament.entity;

import com.zh.jbet.core.entity.GameContext;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 * @author sonrisa
 */
public class ContextMatches {
    private GameContext context;
    private List<Team> teams;

    public String getName() {
        return context.getName();
    }

    public String getShortName() {
        return context.getShortName();
    }

    public Date getStartTime() {
        return context.getStartTime();
    }

    public boolean isFinished() {
        return context.isFinished();
    }

    public List<Team> getTeams() {
        return teams;
    }

    public void setTeams(List<Team> teams) {
        this.teams = teams;
    }

    public GameContext getContext() {
        return context;
    }

    public void setContext(GameContext context) {
        this.context = context;
    }
    
    public List<TeamMatch> generateMatches() {
        List<TeamMatch> matches = new ArrayList<TeamMatch>();
        for (Team thome: teams) {
            for (Team taway: teams) {
                if (!thome.equals(taway)) {
                    TeamMatch m = new TeamMatch();
                    m.setHome(thome);
                    m.setAway(taway);
                    matches.add(m);
                }
            }
        }
        return matches;
    }
}
